using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace JQueryControlToolkit.Controls
{
	public class CssOptions : JSObject
	{
		private Dictionary<string, string> values;
		public CssOptions(string style, Page page)
		{
			this.values = new Dictionary<string, string>();
			CssStyleCollection cssStyle = new Style().GetStyleAttributes(page);
			cssStyle.Value = style;
			foreach (string key in cssStyle.Keys)
			{
				this.values.Add(new Regex("-([a-z])").Replace(key, (Match match) => match.Groups[1].Value.ToUpper()), cssStyle[key]);
			}
		}
		public string ToScript()
		{
			return Extensions.ToScript(this);
		}
		public void ToScript(TextWriter toScript)
		{
			toScript.Write("{");
			bool isFirst = true;
			foreach (KeyValuePair<string, string> css in this.values)
			{
				if (isFirst)
				{
					isFirst = false;
				}
				else
				{
					toScript.Write(", ");
				}
				toScript.Write(DomResult.Escape(css.Key) + ":" + DomResult.Escape(css.Value));
			}
			toScript.Write("}");
		}
	}
}
